package model;

public class Player {
	private String name;
	private int money = 500;
	private String sessionId;
	private String seatNumber;
	private Hand hand = null;
	private int bet = 0;
	private boolean hasFolded = false;
	private boolean isSmallBlind = false;
	private boolean isBigBlind = false;
	private boolean isDealerButton = false;
	private boolean isLastToAct = false;
	private boolean isTurn = false;
	private boolean canRaise = false;
	private boolean canCall = false;
	private boolean canFold = false;
	private boolean canCheck = false;
	
	
	
	public Player(String name, String sessionId, String seatNumber){
		this.name = name;
		this.sessionId = sessionId;
		this.seatNumber = seatNumber;
	}
	
	public String getBlindType(){
		String output = "Normal";
		if(isDealerButton)
			output = "Dealer Button";
		else if(isSmallBlind)
			output = "Small Blind";
		else if(isBigBlind)
			output = "Big Blind";
		
		return output;
	}
	
	public void resetAllFields(){
		this.hasFolded = false;
		this.isLastToAct = false;
		this.isTurn = false;
		this.canRaise = false;
		this.canCall = false;
		this.canFold = false;
		this.canCheck = false;
	}
	
	public int payBlind(int bigBlind){		//if a player is the small or big blind, he immediately pays, if not, do nothing
		int fee = 0;
		if(this.isSmallBlind)
			fee = bigBlind/2;
		else if(this.isBigBlind){
			fee = bigBlind;
			this.isLastToAct = true;
		}
		this.money = this.money - fee;
		this.bet = fee;
		return fee;
	}

	public int raise(int lastTableBet, int amount){

		int currentBet = call(lastTableBet);
		this.money = this.money - amount;
		currentBet = currentBet + amount;
		this.bet = currentBet;
		this.isTurn = false;
		this.isLastToAct = true;
		
		return currentBet;
	}
	
	public int call(int lastTableBet){
		int currentBet = lastTableBet - this.bet;
		this.money = this.money - currentBet;
		this.bet = this.bet + currentBet;
		this.isTurn = false;
		this.isLastToAct = true;

		

		return this.bet;
	}
	
	public void check(){
		this.isTurn = false;
		this.isLastToAct = true;
	}
	
	public void fold(){
		this.hasFolded = true;
		this.isTurn = false;
		this.isLastToAct = true;
	}


	
	
	
	public Boolean verifyBet(){
		return false;
	}
	
	public void allIn(){
		
	}

	public void setName(String name) {
		this.name = name;
	}
	public String getName() {
		return name;
	}
	public void setSmallBlind(boolean isSmallBlind) {
		this.isSmallBlind = isSmallBlind;
	}
	public boolean isSmallBlind() {
		return isSmallBlind;
	}
	public void setMoney(int money) {
		this.money = money;
	}
	public int getMoney() {
		return money;
	}
	public void setBigBlind(boolean isBigBlind) {
		this.isBigBlind = isBigBlind;
	}
	public boolean isBigBlind() {
		return isBigBlind;
	}
	public void setSessionId(String sessionId) {
		this.sessionId = sessionId;
	}
	public String getSessionId() {
		return sessionId;
	}
	public void setSeatNumber(String seatNumber) {
		this.seatNumber = seatNumber;
	}
	public String getSeatNumber() {
		return seatNumber;
	}
	public void setDealerButton(boolean isDealerButton) {
		this.isDealerButton = isDealerButton;
	}
	public boolean isDealerButton() {
		return isDealerButton;
	}
	public void setHand(Hand hand) {
		this.hand = hand;
	}
	public Hand getHand() {
		return hand;
	}
	public void setLastToAct(boolean isLastToAct) {
		this.isLastToAct = isLastToAct;
	}
	public boolean isLastToAct() {
		return isLastToAct;
	}
	public void setTurn(boolean isTurn) {
		this.isTurn = isTurn;
	}
	public boolean isTurn() {
		return isTurn;
	}
	public void setCanRaise(boolean canRaise) {
		this.canRaise = canRaise;
	}
	public boolean isCanRaise() {
		return canRaise;
	}
	public void setCanCall(boolean canCall) {
		this.canCall = canCall;
	}
	public boolean isCanCall() {
		return canCall;
	}
	public void setCanFold(boolean canFold) {
		this.canFold = canFold;
	}
	public boolean isCanFold() {
		return canFold;
	}
	public void setCanCheck(boolean canCheck) {
		this.canCheck = canCheck;
	}
	public boolean isCanCheck() {
		return canCheck;
	}
	public void setBet(int bet) {
		this.bet = bet;
	}
	public int getBet() {
		return bet;
	}
	public void setHasFolded(boolean hasFolded) {
		this.hasFolded = hasFolded;
	}
	public boolean hasFolded() {
		return hasFolded;
	}
}